<template>
	<view class="participant">
		<view class="participant_list" v-for="(item, index) in singupPeople" :key="index">
			<view class="cont">
				<image :src="item.head_url" mode=""></image>
				<span>{{ item.MemberName }}</span>
				<span v-if="item.sign_num > 1">({{ item.sign_num }}人)</span>
			</view>
			<view class="time" v-if="type != 1">
				<view class="time_item">{{ item.day }}</view>
				<view class="time_item">{{ item.hour }}</view>
			</view>
			<view class="time" v-else>
				<view class="time_item">{{ item.start_end }}</view>
			</view>
		</view>
		<navigation></navigation>
	</view>
</template>

<script>
import navigation from '@/components/navigation/navigation.vue';
export default {
	components: {
		navigation
	},
	data() {
		return {
			active_id: '',
			singupPeople: [],
			currentpage: '1',
			last_page: '',
			type: ''
		};
	},
	onLoad(options) {
		this.active_id = options.id;
		this.type = options.type;
	},
	onReachBottom() {
		if (this.currentpage == this.last_page) {
			this.toast('没有更多数据了');
			return;
		}
		this.toast('数据加载中');
		this.currentpage++;
		this.getsingupPeople();
	},
	mounted() {
		this.getsingupPeople();
	},
	methods: {
		// 获取报名人数据
		getsingupPeople() {
			var nowTime = new Date().getTime();
			this.ajax('active/activeSignInfo', {
				data: {
					active_id: this.active_id
				},
				success: res => {
					if (res.code) {
						res.msg.forEach(item => {
							item.head_url = item.head_url.replace("http:", "https:")
							var time = new Date(item.create_time).getTime();
							var leadtime = nowTime - time;
							 // console.log (leadtime);
							if (leadtime >= 60000 && leadtime < 3600000) {
								item.start_end = parseInt(leadtime / 60000) + '分钟前';
							} else if (leadtime >= 3600000 && leadtime < 86400000) {
								item.start_end = parseInt(leadtime / 3600000) + '小时前';
							} else if (leadtime >= 86400000 && leadtime < 2592000000) {
								item.start_end = parseInt(leadtime / 86400000) + '天前';
							} else if (leadtime >= 2592000000 && leadtime < 31104000000) {
								item.start_end = parseInt(leadtime / 2592000000) + '月前';
							} else if (leadtime < 60000) {
								item.start_end = '1分钟内'
							} else if(leadtime > 31104000000){
								item.start_end = parseInt(leadtime / 31104000000) + '年前';
							}
							var m = [];
							m = item.create_time.split(' ')[0].split('-');
							item.day = m[1] + '/' + m[2];
							item.hour = item.create_time.split(' ')[1].slice(0, 5);
						});
						this.singupPeople = res.msg;
					}
					 // console.log (res);
					// res.msg.forEach( (item) => {
					// 	item.form.forEach ( (items) =>{
					// 		if(items.name == '姓名') {
					// 			item.name = items.value
					// 		}
					// 	})
					// })
					// this.singupPeople_people = res.msg.total
				}
			});
		}
	}
};
</script>

<style lang="less" scoped>
page {
	background-color: #f2f2f2 !important;
}
.participant {
	background-color: #ffffff;
	padding: 0 30upx;
	box-sizing: border-box;
	.participant_list {
		height: 126upx;
		display: flex;
		align-items: center;
		border-top: 2upx solid #e1e1e1;
		box-sizing: border-box;
		display: flex;
		justify-content: space-between;
		.time {
			display: flex;
			align-items: center;
			.time_item {
				font-size: 28upx;
				color: #999;
				margin-left: 20upx;
			}
		}
		.cont {
			display: flex;
			align-items: center;
			image {
				width: 86upx;
				height: 86upx;
				border-radius: 50%;
				margin-right: 20upx;
			}
			span {
				font-size: 28upx;
				color: #333333;
			}
		}
	}
	.participant_list:first-child {
		border-top: 0;
	}
}
</style>
<style>
page {
	background-color: #f2f2f2;
}
</style>
